﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StateManager
{
    class MultiPlayerMenu : GenericMenu
    {
        enum Players
        {
            Two = 2,
            Three,
            Four,
        }

        Players plrs = Players.Two;
        MenuItems Play;
        MenuItems PlayerEntries;
        MenuItems Back;
        

        public MultiPlayerMenu()
            : base("Multiplayer Menu")
        {
            Play = new MenuItems("Start game");
            PlayerEntries = new MenuItems(String.Empty);
            Back = new MenuItems("Go back");
            
            SetUpMenuText();
            Play.Selected += PlayGameItemSelected;
            PlayerEntries.Selected += PlayerItemSelected;
            Back.Selected += OnCancel;
            MenuEntries.Add(Play);
            MenuEntries.Add(PlayerEntries);
            MenuEntries.Add(Back);    
        }

        void PlayGameItemSelected(object sender, PlayerEventHandler e)
        {
            //currentUngulate++;

            //if (currentUngulate > Ungulate.Llama)
            //    currentUngulate = 0;

            //SetMenuEntryText();
            LoadScreen.Load(SManager, true, e.PlayerIndex, new MultiGameScreen((int)plrs));
        }

        void PlayerItemSelected(object sender, PlayerEventHandler e)
        {
            plrs++;

            if (plrs > Players.Four)
                plrs = Players.Two;

            SetUpMenuText();
        }

        void SetUpMenuText()
        {
            PlayerEntries.Text = String.Format("Players : " + (int)plrs);
        }
    }
}
